<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use OSS;
use App\Models\Product;
use App\Models\ProductImg;

class IndexController extends Controller
{
    public function index(Request $request)
    {
    	$list = Product::select(['id','name','thumb','created_at'])
                        ->orderBy('created_at','desc')
                        ->paginate(20);
        //dd($list);
		return view('photo.index',compact('list'));

    }

    public function gallery(Request $request)
    {
    	$product_id = $request->product_id;
    	$product = Product::find($product_id);
        $imgs = ProductImg::where(['product_id'=>$product_id])->get();
        return view('photo.gallery',compact('product','imgs'));
    }

    public function download(Request $request)
    {
        
    }
}
